package oldGui;

import invoiceManager.InvoiceBatch;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.swing.JPanel;
import javax.swing.Timer;


public class InvoiceManagerMain extends JPanel {
	
	private Timer timer;
	private InvoiceListener iL;
	File currentFile;
	private long currentTimeStamp;
	/**
	 * Create the panel.
	 * @throws IOException 
	 */
	public InvoiceManagerMain() throws IOException {
		currentFile = new File("C:\\Users\\jedwards.MMO\\Desktop\\Development\\CCINV");//new File("Z:\\CCINV");
		currentTimeStamp = currentFile.lastModified();
		
		iL = new InvoiceListener();
		timer = new Timer(10000, iL);//10 second for debug
		timer.start();
		
	
		
	}
	
	private void checkInvoice() throws FileNotFoundException {
		File checkFile = new File("C:\\Users\\jedwards.MMO\\Desktop\\Development\\CCINV");
		//if(checkFile.lastModified() != currentTimeStamp){
			InvoiceBatch ib = new InvoiceBatch(checkFile);
		//}
		
		
	}
	
	private class InvoiceListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			if(e.getSource() == timer){
				try{
					checkInvoice();
				}
				catch(Exception e1){
					
				}
			}
			
		}


		
	}

}
